package rocketmq.demo.sync.trans;

import java.util.Date;

import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.remoting.common.RemotingHelper;

public class SyncProducer2 {
	public static void main(String[] args) throws Exception {
		DefaultMQProducer producer = new DefaultMQProducer("testGroup2");
		// 指定nameServer的地址 （测试时在代码中指定）
		producer.setNamesrvAddr("127.0.0.1:9876");
		producer.start();
		for (int i = 0; i < 3; i++) {
			String content = "你好  RocketMQ, " + new Date().getTime() + "-->" + i;
			Message message = new Message("TopicSync", "testTag2", content.getBytes(RemotingHelper.DEFAULT_CHARSET));
			SendResult sendResult = producer.send(message);
			System.out.printf("%s%n", sendResult);
		}
		producer.shutdown();
	}
}
